how to fix java.lang.illegalstateexception